package service.serviceImpl;

import mapper.UserMapper;
import org.springframework.stereotype.Service;
import pojo.User;
import service.UserService;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by Dell on 2019/1/3.
 */
@Service("userService")
public class UserServiceImpl implements UserService{

    @Resource
    private UserMapper userMapper;
    public List<User> getUserInfo(User user){
        try {
            return userMapper.getUserInfo(user);
        }catch (RuntimeException e){
            e.printStackTrace();
            throw e;
        }
    }
    public boolean addUserInfo(User user){
        boolean result=false;
        try {
            if(userMapper.addUserInfo(user))
               result=true;
        }catch (RuntimeException e){
            e.printStackTrace();
            throw e;
        }
        return result;
    }

    public User Login(User user){
        if (userMapper.login(user) != null) {
            return userMapper.login(user);
        } else {
            return null;
        }
    }
}
